﻿using BCDto.WeChatComponent.WeChatCustomMenu;
using BCService.WeChatComponent.WeChatCustomMenuService;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;

namespace BCTMSRESTful.Controllers.Management.WeChat
{
    /// <summary>
    /// 微信自定义菜单控制器
    /// </summary>
    [ApiExplorerSettings(GroupName = "Admin")]
    [Route("api/v1/sim/[controller]")]
    public class WeChatCustomMenuController : ManagementBaseController
    {
        private readonly IWeChatCustomMenuService weChatCustomMenuService;

        public WeChatCustomMenuController(IWeChatCustomMenuService weChatCustomMenuService)
        {
            this.weChatCustomMenuService = weChatCustomMenuService;
        }

        /// <summary>
        /// 添加微信自定义菜单信息。
        /// </summary>
        /// <param name="weChatCustomMenuRequestDto">微信自定义菜单信息</param>
        /// <response code="201">已添加成功的微信自定义菜单信息。</response>
        /// <returns></returns>
        [HttpPost]
        [ProducesResponseType(typeof(WeChatCustomMenuDto), 200)]
        public IActionResult Post([FromBody]WeChatCustomMenuRequestDto weChatCustomMenuRequestDto)
        {
            WeChatCustomMenuDto result = this.weChatCustomMenuService.Add(weChatCustomMenuRequestDto);
            return this.Created(string.Format("/api/v1/sim/WeChatCustomMenu/{0}", result.WeChatCustomMenuId), result);
        }
        /// <summary>
        /// 修改微信自定义菜单信息。
        /// </summary>
        /// <param name="weChatCustomMenuId">微信自定义菜单Id</param>
        /// <param name="weChatCustomMenuRequestDto">微信自定义菜单信息</param>
        /// <response code="200">修改成功的微信自定义菜单信息。</response>
        /// <returns></returns>
        [HttpPut("{we_chat_custom_menu_id}")]
        [ProducesResponseType(typeof(WeChatCustomMenuDto), 200)]
        public IActionResult Put([FromRoute(Name = "we_chat_custom_menu_id")]int weChatCustomMenuId, [FromBody]WeChatCustomMenuRequestDto weChatCustomMenuRequestDto)
        {
            return this.Ok(this.weChatCustomMenuService.Update(weChatCustomMenuId, weChatCustomMenuRequestDto));
        }
        /// <summary>
        /// 删除微信自定义菜单信息。
        /// </summary>
        /// <param name="weChatCustomMenuId">微信自定义菜单Id</param>
        /// <response code="204">删除成功</response>
        /// <returns></returns>
        [HttpDelete("{we_chat_custom_menu_id}")]
        public IActionResult Delete([FromRoute(Name = "we_chat_custom_menu_id")]int weChatCustomMenuId)
        {
            this.weChatCustomMenuService.Delete(weChatCustomMenuId);
            return this.Ok();
        }
        /// <summary>
        /// 获取微信自定义菜单列表。
        /// </summary>
        /// <response code="200">获取微信自定义菜单列表。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(IEnumerable<WeChatCustomMenuDto>), 200)]
        public IActionResult Get()
        {
            return this.Ok(this.weChatCustomMenuService.GetList());
        }
        /// <summary>
        /// 获取微信自定义菜单信息。
        /// </summary>
        /// <param name="weChatCustomMenuId">自定义菜单Id</param>
        /// <response code="200">获取的微信自定义菜单信息。</response>
        /// <returns></returns>
        [HttpGet("{we_chat_custom_menu_id}")]
        [ProducesResponseType(typeof(IEnumerable<WeChatCustomMenuDto>), 200)]
        public IActionResult Get([FromRoute(Name = "we_chat_custom_menu_id")]int weChatCustomMenuId)
        {
            return this.Ok(this.weChatCustomMenuService.Get(weChatCustomMenuId));
        }
        /// <summary>
        /// 移除微信服务器自定义菜单。
        /// </summary>
        /// <response code="200">移除是否成功。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(bool), 200)]
        public IActionResult DeleteWeChatMenu()
        {
            return this.Ok(this.weChatCustomMenuService.RemoveWeChatMenu());
        }

        /// <summary>
        /// 发布微信服务器自定义菜单。
        /// </summary>
        /// <response code="200">发布是否成功。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(bool), 200)]
        public IActionResult PushMenu()
        {
            return this.Ok(this.weChatCustomMenuService.PushMenu());
        }
    }
}
